<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="Model.Mobile" %>
<%@page import="java.util.*" %>
<%Mobile mb = new Mobile();%>
<div id="rightside">
    <%@include file="slide.jsp" %>
     <%          String categoryName = "";
                int limit = 4;
                int cat = 1;
                boolean viewAll = false;
                Mobile[] mobiles;
                String category = request.getParameter("cat");
                if (category != null) {
                    cat = Integer.parseInt(category);
                    limit = cat+1;
                } else {
                    viewAll = true;
                }

                int k = 0;
                while(cat<limit) {
                    if (cat == 1) {
                        categoryName = "CAO CẤP";
                    }
                    if (cat == 2) {
                        categoryName = "TRUNG CẤP";
                    }
                    if (cat == 3) {
                        categoryName = "PHỔ THÔNG";
                    }
                    mobiles = (Mobile[]) mb.getMobileByCategory(cat, viewAll);
    %>

    <div id="<%=categoryName%>" style="margin-left:5px;margin-top:50px;">
        <div class="box_header">
            <h4 class="title_center"><a href="index.jsp?cat=<%=cat%>" style="color: #0033CC;font-weight: bold;"><%=categoryName%></a></h4>
        </div >
        <div class="box_center">
            <table width="100%" border="0" cellspacing="5" cellpadding="5">
                <%
                                    int i = 0;
                                    while (i < mobiles.length) {
                                        int j = 0;
                %>
                <tr>
                    <% while (j < 3 && i < mobiles.length) {%>

                    <td>

                        <div class="itemoff" onmouseover="className='itemon';" onmouseout="className='itemoff';">
                            

                                <div class="image">
                                    <img width="59" height="88" src="<%=mobiles[i].getAnhDaiDien()%>" border="0" /> </div>
                                <div class="name">
                                    <a href="tooltip/tooltipmobile.jsp?id=<%=mobiles[i].getMobileID()%>"
                                       name=" <%=mobiles[i].getTenSP()%>" id="<%=k++%>" class="jTip">
                                        <%=mobiles[i].getTenSP()%>
                                    </a>
                                </div>
                               
                                <div class="giaa" style="background-image:url('image/bg-price.png');background-repeat: no-repeat;height: 29px;width: 139px;margin: auto; padding-top: 6px;color: white;"> <strong><%= mobiles[i].formatedPrice()%> VND</strong>
                                </div>
                                <div class="chitiet"><a href="DetailProduct?mobileID=<%=mobiles[i].getMobileID()%>"><img src="image/bg-nutchitiet.png"></a></div>

   								 <div class="dathang"><a href="Order?mobileID=<%=mobiles[i].getMobileID()%>"><img src="image/bg-nutgiohang.png"></a></div>
                                
                                
                           
                        </div>

                    </td>

                    <% j++;
                                                                i++;
                                                            }%>
                </tr>
                <% }%>

            </table>

        </div>

    </div>
    <%cat++;}%>




</div>